package com.lizheng.yunservice.goods.service.impl;

import com.lizheng.yunservice.goods.mapper.VtpGoodsSellerMapper;
import com.lizheng.yunservice.goods.model.VO.VtpGoodsSellerVO;
import com.lizheng.yunservice.goods.model.VtpGoodsSeller;
import com.lizheng.yunservice.goods.service.IVtpGoodsSellerService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class VtpGoodsSellerServiceImpl implements IVtpGoodsSellerService {

    @Autowired
    private VtpGoodsSellerMapper sellerMapper;

    @Override
    public List<VtpGoodsSellerVO> getByGoodsId(Long goodsId) {
        List<VtpGoodsSeller> entities = sellerMapper.selectByGoodsId(goodsId);
        return entities.stream().map(entity -> {
            VtpGoodsSellerVO vo = new VtpGoodsSellerVO();
            BeanUtils.copyProperties(entity, vo);
            return vo;
        }).collect(Collectors.toList());
    }
}